package com.example.showlocation;

import android.annotation.SuppressLint;
import android.app.PendingIntent;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

import com.tencent.tencentmap.mapsdk.maps.CameraUpdate;
import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory;
import com.tencent.tencentmap.mapsdk.maps.MapView;
import com.tencent.tencentmap.mapsdk.maps.TencentMap;
import com.tencent.tencentmap.mapsdk.maps.TencentMapInitializer;
import com.tencent.tencentmap.mapsdk.maps.model.CameraPosition;
import com.tencent.tencentmap.mapsdk.maps.model.LatLng;

import java.io.IOException;

public class ShowMapActivity extends AppCompatActivity {
    MapView mapView;
    TencentMap mTencentMap;
    @Override
    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_show_map);
        TencentMapInitializer.setAgreePrivacy(true);
         mapView =findViewById(R.id.view6) ;
         mTencentMap = mapView.getMap();
    }
    @SuppressLint("UseCompatLoadingForDrawables")
    protected void onStart() {
        super.onStart();

//第一次渲染成功的回调
        /*mTencentMap.setOnMapLoadedCallback(new TencentMap.OnMapLoadedCallback() {
            public void onMapLoaded() {
                //地图正常显示
                Log.d(getLocalClassName()+":", "onMapLoaded()");
            }
        }*/

        Log.d(getLocalClassName()+":", "onStart()");
    }
    protected void onResume() {
        super.onResume();
        Log.d(getLocalClassName()+":", "onResume()");
    }
    protected void onPause() {
        super.onPause();
        Log.d(getLocalClassName()+":", "onPause()");
    }
    protected void onStop() {
        super.onStop();
        Log.d(getLocalClassName()+":", "onStop()");
    }
    protected void onRestart() {
        super.onRestart();
        Log.d(getLocalClassName()+":", "onRestart()");
    }
    protected void onDestroy() {
        super.onDestroy();
        Log.d(getLocalClassName()+":", "onDestroy()");
    }
    @SuppressLint("IntentReset")
    public void sendMessage_2(View view) throws IOException, PendingIntent.CanceledException {
        //mTencentMap.setMapType(TencentMap.MAP_TYPE_SATELLITE);

        Log.d(getLocalClassName()+":", "sendMessage_2(View view)");
    }
    @SuppressLint("IntentReset")
    public void sendMessage_3(View view) throws IOException, PendingIntent.CanceledException {
        //mTencentMap.setMapType(TencentMap.MAP_TYPE_DARK);
        CameraUpdate cameraSigma =
                CameraUpdateFactory.newCameraPosition(new CameraPosition(
                        new LatLng(40.977290,116.337000), //中心点坐标，地图目标经纬度
                        19,  //目标缩放级别
                        0f, //目标倾斜角[0.0 ~ 45.0] (垂直地图时为0)
                        0f)); //目标旋转角 0~360° (正北方为0)
        mTencentMap.moveCamera(cameraSigma);
        Log.d(getLocalClassName()+":", "sendMessage_3(View view)");
    }
    @SuppressLint("IntentReset")
    public void sendMessage_4(View view) throws IOException, PendingIntent.CanceledException {
        mTencentMap.setMyLocationClickListener(new TencentMap.OnMyLocationClickListener() {
            @Override
            public boolean onMyLocationClicked(LatLng latLng) {

                return true;
            }
        });
        Log.d(getLocalClassName()+":", "sendMessage_4(View view)");
    }

}